<template>
	<view >
		<my-header bgColor="bg-gradual-blue" bgCol="#f45a8d" :isBack="true" >
			<block slot="backText">返回</block>
			<block slot="content">首页</block>
		</my-header>
		<swiper class="screen-swiper" :class="dotStyle?'square-dot':'round-dot'" :indicator-dots="true" :circular="true"
		 :autoplay="true" interval="5000" duration="500">
			<swiper-item v-for="(item,index) in swiperList" :key="index">
				<image :src="item.url" mode="aspectFill" ></image>
				<image :src="item.url" mode="aspectFill" v-if="item.type=='image'"></image>
				<video :src="item.url" autoplay loop muted :show-play-btn="false" :controls="false" objectFit="cover" v-if="item.type=='video'"></video>
			</swiper-item>
		</swiper>
		<view class="list row">
            <view class="item col" v-for="(item,index) in dataList" :key="index" @click="go('./video/video?id='+index)">
                <image class="main_img" :src="item.main_img" mode="" />
                <view class="title">{{item.title}}</view>
            </view>
        </view>
        <loading v-if="!is_req"></loading>

		<!-- <my-footer cur="0"></my-footer> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
                dataList:[],
                is_req:false
			}
		},
		
		created(){
			this.initData()	

        },
		methods: {
			async initData(){
                let url ="https://rest.apizza.net/mock/1244df158580e3f345a24358f5bd6d0e/hu_list"
				const res=await uni.$request({
				},url)
                this.dataList=res.data.list
                this.is_req=true
                uni.setStorageSync('dataList', res.data.list)
				console.log(res);
			},
			go(link){
				if (link) {
					uni.navigateTo({
						url:link,
						success:(res)=>{
							console.log(res);
						},
						fail:(err)=>{
							console.log(err);
						}
					});
				}else{
					let url="http://localhost:8080/"
					let openid= uni.getStorageSync('openid')
					this.copy(url+"?"+openid)
				}
				
			},
			copy(data){
                uni.setClipboardData({
                    data,
                    success: function () {
                       uni.$err("请前往浏览器打开")
                    }
                });
            },
		}
	}
</script>

<style lang="scss">
	@import "../main";
</style>